/**
 * Created by Administrator on 2018/4/24.
 */
/**
 * Created by zackey on 2016/5/28.
 */
var messages = new Vue();
define(function (require,exports,module) {
    require("./lib/fullcalendar/moment.min.js")
    const routes = [{
        path:"/appointment/enter"   ,component:function (resolve) {
            require.async(['modules/appointment/enter/enter.js'],resolve);
        },
        meta:{"tittle":"预约录入"}
    }
        , {
            path:"/appointment/examine"   ,component:function (resolve) {
                require.async(['modules/appointment/examine/examine.js'],resolve);
            },
            meta:{"tittle":"预约信息管理"}
        },
        , {
            path:"/flatTupo"   ,component:function (resolve) {
                require.async(['modules/machineFlatMonitoring/flatTupo/flatTupo.js'],resolve);
            },
            meta:{"tittle":"预约信息管理"}
        }

        , {
            path:"/sysSetting/rooms"   ,component:function (resolve) {
                require.async(['modules/sysSetting/rooms/room.js'],resolve);
            },
            meta:{"tittle":"房间配置"}
        }
        , {
            path:"/sigin/sigin/"   ,component:function (resolve) {
                require.async(['modules/sigin/sigin/sigin.js'],resolve);
            },
            meta:{"tittle":"签入"}
        }
        , {
            path:"/sigin/serviceStatus/"   ,component:function (resolve) {
                require.async(['modules/sigin/serviceStatus/serviceStatus.js'],resolve);
            },
            meta:{"tittle":"服务动态"}
        }
        , {
            path:"/sigin/signInManager/"   ,component:function (resolve) {
                require.async(['modules/sigin/signInManager/signInManager.js'],resolve);
            },
            meta:{"tittle":"签入管理"}
        }
        , {
            path:"/planeProject/flyRequest"   ,component:function (resolve) {
                require.async(['modules/planeProject/flyRequest/flyRequest.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/planeProject/query"   ,component:function (resolve) {
                require.async(['modules/planeProject/query/flyRequestManager.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/vehicle/vehicleBase/"   ,component:function (resolve) {
                require.async(['modules/vehicle/vehicleBase/vehicleBase.js'],resolve);
            },
            meta:{"tittle":"接送服务"}
        }
        , {
            path:"/flightInfo/enter/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/flightInfo/enter/enter.js'],resolve);

            },
            meta:{}
        }
        , {
            path:"/flightInfo/query/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/flightInfo/query/query.js'],resolve);
            },
            meta:{"tittle":"航空器基础信息管理"}
        }
        , {
            path:"/flightPlanes/mediumAndLongs"   ,component:function (resolve) {
                require.async(['modules/flightPlane/mediumAndLong/flightPlane.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/flightPlane/appoFlightPlane"   ,component:function (resolve) {
                require.async(['modules/flightPlane/appoFlightPlane/flightPlane.js'],resolve);
            },
            meta:{"tittle":"预约航班计划"}
        }
        , {
            path:"/flightPlane/enter/"   ,component:function (resolve) {
                require.async(['modules/flightPlane/excelEnter/enter.js'],resolve);

            },
            meta:{}
        }
        , {
            path:"/machineFlatMonitoring/gante/"   ,component:function (resolve) {
                require.async(['modules/machineFlatMonitoring/gante.js'],resolve);

            },
            meta:{"tittle":"机坪监控"}
        }
        , {
            path:"/flightPlane/query/:type"   ,component:function (resolve) {
                require.async(['modules/flightPlane/query/query.js'],resolve);

            },
            meta:{}
        }
        , {
            path:"/groundServiceScheduling/serviceBill"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/serviceBill/serviceBill.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/flightPlane/gante"   ,component:function (resolve) {
                require.async(['modules/flightPlane/gante/gante.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/sysSetting/contractManage/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/contractManage/contractManage.js'],resolve);

            },
            meta:{"tittle":"合同配置"}
        }
        , {
            path:"/groundServiceScheduling/query/"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/query/query.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/sysSetting/contractManage/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/contractManage/contractManage.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/sysSetting/gpConfigMgr/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/gpConfigMgr/gpConfig.js'],resolve);
            },
            meta:{"tittle":"停机位配置"}
        }
        , {
            path:"/sysmgr/fboModuleMgr/"   ,component:function (resolve) {
                require.async(['sysmgr/fboModuleMgr/fboModuleMgr.js'],resolve);

            },
            meta:{"tittle":"权限管理"}
        }
        , {
            path:"/sysmgr/fboRoleMgr/"   ,component:function (resolve) {
                require.async(['sysmgr/fboRoleMgr/fboRoleMgr.js'],resolve);

            },
            meta:{"tittle":"角色管理"}
        }
        , {
            path:"/sysmgr/fboUserMgr/"   ,component:function (resolve) {
                require.async(['sysmgr/fboUserMgr/fboUserMgr.js'],resolve);

            },
            meta:{}
        }
        , {
            path:"/sysmgr/deptMgr/:type"   ,component:function (resolve) {
                require.async(['sysmgr/deptMgr/deptMgr.js'],resolve);
            },
            meta:{}
        }
        , {
            path:"/groundServiceScheduling/scheduling/"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/scheduling/schedule.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/groundServiceScheduling/scheduling2/"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/scheduling2/schedule.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/groundServiceScheduling/schedulingNew/"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/schedulingNew/schedule.js'], resolve);
            },
            meta:{"tittle":"地服项目配置"}
        }
        , {
            path:"/modules/groundServiceScheduling/duty"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/duty/duty.js'], resolve);
            },
            meta:{"tittle":"日值班表"}
        }
        , {
            path:"/groundServiceScheduling/dutyOfWeek"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/dutyOfWeek/dutyOfWeek.js'], resolve);
            },
            meta:{"tittle":"周值班表"}
        }
        , {
            path:"/groundServiceScheduling/scheduleTableNew/"   ,component:function (resolve) {
                require.async(['modules/groundServiceScheduling/scheduleTableNew/scheduleTable.js'], resolve);
            },
            meta:{"tittle":"人员排班管理"}
        }
        , {
            path:"/sysmgr/userMgr/"   ,component:function (resolve) {
                require.async(['sysmgr/userMgr/userMgr.js'], resolve);
            },
            meta:{"tittle":"用户管理"}
        }
        , {
            path:"/maintenanceAndMaintenance/equipment/"   ,component:function (resolve) {
                require.async(['modules/maintenanceAndMaintenance/equipment/equipManager.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/maintenanceAndMaintenance/maintenancePlan/"   ,component:function (resolve) {
                require.async(['modules/maintenanceAndMaintenance/maintenancePlan/maintenancePlanManager.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/maintenanceAndMaintenance/maintenceRecord/"   ,component:function (resolve) {
                require.async(['modules/maintenanceAndMaintenance/maintenceRecord/maintenceRecordManager.js'], resolve);

            },
            meta:{}
        }
        , {
            path:"/aircraftPreloading/"   ,component:function (resolve) {
                require.async(['modules/aircraftPreloading/aircraftPreloading.js'], resolve);
            },
            meta:{"tittle":"智慧配载管理"}
        }
        , {
            path:"/inventoryManagement/inventoryBasic/"   ,component:function (resolve) {
                require.async(['modules/inventoryManagement/inventoryBasic/inventoryBasic.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/inventoryManagement/stockInRecord/"   ,component:function (resolve) {
                require.async(['modules/inventoryManagement/stockInRecord/stockInRecord.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/purchaseMgr/purchasePlan/"   ,component:function (resolve) {
                require.async(['modules/purchaseMgr/purchasePlan/purchasePlan.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/inventoryManagement/supplierMgr/"   ,component:function (resolve) {
                require.async(['modules/inventoryManagement/supplierMgr/supplierMgr.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/purchaseMgr/purchaseOrder/"   ,component:function (resolve) {
                require.async(['modules/purchaseMgr/purchaseOrder/order.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/purchaseMgr/purchaseOrderList/"   ,component:function (resolve) {
                require.async(['modules/purchaseMgr/purchaseOrderList/purchaseOrderList.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/maintenanceAndMaintenance/repairPlan/"   ,component:function (resolve) {
                require.async([' modules/maintenanceAndMaintenance/repairPlan/repairPlanManager.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/maintenanceAndMaintenance/flight/"   ,component:function (resolve) {
                require.async(['modules/maintenanceAndMaintenance/flight/flightManager.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/"   ,component:function (resolve) {
                require.async(['modules/productionCase1/productionCase.js'], resolve);
            },
            meta:{"tittle":"生产实况"}
        }
        , {
            path:"/flightDynamic/"   ,component:function (resolve) {
                require.async(['modules/flightDynamic/processKanban/processKanban.js'], resolve);

            },
            meta:{"tittle":"航班动态"}
        }
        , {
            path:"/flightCrewMgr/certificateMgr/"   ,component:function (resolve) {
                require.async(['modules/flightCrewMgr/certificateMgr/certificateMgr.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/aircraftPreloading/aircraftPreloadingBasic/"   ,component:function (resolve) {
                require.async(['modules/aircraftPreloading/aircraftPreloadingBasic/aircraftPreloading.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/productionCase/productionCase/"   ,component:function (resolve) {
                require.async(['modules/productionCase1/productionCase.js'], resolve);
            },
            meta:{"tittle":"生产实况"}
        }
        , {
            path:"/processControl/processKanban/"   ,component:function (resolve) {
                require.async(['modules/processControl/processKanban/processKanban.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/flightPlane/interimFlight/"   ,component:function (resolve) {
                require.async(['modules/flightPlane/interimFlight/interimFlight.js'], resolve);

            },
            meta:{"tittle":"临时航班计划"}
        }
        , {
            path:"/processDetails/"   ,component:function (resolve) {
                require.async(['modules/processDetails/processDetails.js'], resolve);

            },
            meta:{"tittle":"进程管控"}
        }
        , {
            path:"/vehicle/airSecurityVehicle/"   ,component:function (resolve) {
                require.async(['modules/vehicle/airSecurityVehicle/airSecurityVehicle.js'], resolve);

            },
            meta:{"tittle":"地面保障车辆"}
        }
        , {
            path:"/mapMigration/"   ,component:function (resolve) {
                require.async(['modules/mapMigration/mapMigration.js'], resolve);

            },
            meta:{}
        }
        , {
            path:"/flightPlane/approvalPlan/"   ,component:function (resolve) {
                require.async(['modules/flightPlane/approvalPlan/approvalPlan.js'], resolve);
            },
            meta:{"tittle":"批文计划"}
        }
        , {
            path:"/appointment/appoFlightPlane/"   ,component:function (resolve) {
                require.async(['modules/appointment/appoFlightPlane/flightPlane.js'], resolve);
            },
            meta:{}
        }
        , {
            path:"/appointment/exmineFlightPlane/"   ,component:function (resolve) {
                require.async(['modules/appointment/exmineFlightPlane/flightPlane.js'], resolve);

            },
            meta:{"tittle":"预约审核"}
        }
        , {
            path:"/weatherAnalysis/"   ,component:function (resolve) {
                require.async(['modules/weatherAnalysis/weatherAnalysis.js'], resolve);
            },
            meta:{"tittle":"气象分析"}
        }
        , {
            path:"/flightPlane/nextDayPlan/"   ,component:function (resolve) {
                require.async(['modules/flightPlane/nextDayPlan/nextDayPlan.js'], resolve);

            },
            meta:{"tittle":"次日计划"}
        }
        , {
            path:"/secProcessControl/"   ,component:function (resolve) {
                require.async(['modules/secProcessControl2/secProcessControl.js'], resolve);

            },
            meta:{"tittle":"保障进程监控"}
        }
        , {
            path:"/vehicle/secVehicleControl/"   ,component:function (resolve) {
                require.async(['modules/vehicle/secVehicleControl/secVehicleControl.js'], resolve);

            },
            meta:{"tittle":"车辆及特种设备管理"}
        }
        , {
            path:"/statisticAnalysis/gatePositionUsed/"   ,component:function (resolve) {
                require.async(['modules/statisticAnalysis/gatePositionUsed/gatePositionUsed.js'], resolve);

            },
            meta:{"tittle":"机位利用率分析"}
        }
        , {
            path:"/statisticAnalysis/aogOvernight/"   ,component:function (resolve) {
                require.async(['modules/statisticAnalysis/aogOvernight/aogOvernight.js'], resolve);

            },
            meta:{"tittle":"停场过夜分析"}
        }
        , {
            path:"/statisticAnalysis/resUseRatio/"   ,component:function (resolve) {
                require.async(['modules/statisticAnalysis/resUseRatio/resUseRatio.js'], resolve);

            },
            meta:{"tittle":"资源利用率分析"}
        }
        , {
            path:"/statisticAnalysis/secRanking/"   ,component:function (resolve) {
                require.async(['modules/statisticAnalysis/secRanking/secRanking.js'], resolve);

            },
            meta:{"tittle":"保障排行分析"}
        }
        , {
            path:"/missionControl/"   ,component:function (resolve) {
                require.async(['modules/missionControl/missionControl.js'], resolve);

            },
            meta:{"tittle":"任务调度及监控"}
        }
        , {
            path:"/sysSetting/flightTypeInfo/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/flightTypeInfo/query/query.js'], resolve);

            },
            meta:{"tittle":"航空器机型配置"}
        }
        , {
            path:"/flightPlane/appoFlightPlaneAdjust"   ,component:function (resolve) {
                require.async(['modules/flightPlane/appoFlightPlaneAdjust/flightPlane.js'], resolve);
            },
            meta:{"tittle":"预约航班预计划"}
        }
        , {
            path:"/messagePush/"   ,component:function (resolve) {
                require.async(['modules/messagePush/messagePush.js'], resolve);
            },
            meta:{"tittle":"消息推送测试"}
        }
        , {
            path:"/sysSetting/courseNodeBase/"   ,component:function (resolve) {
                require.async(['modules/sysSetting/courseNodeBase/courseNodeBase.js'], resolve);
            },
            meta:{"tittle":"保障进程节点配置"}
        }
        , {
            path:"/flightDynamicToday/"   ,component:function (resolve) {
                require.async(['modules/flightDynamicToday/flightDynamicToday.js'], resolve);
            },
            meta:{"tittle":"今日动态"}
        }];

    const router = new VueRouter({
        routes:routes // （缩写）相当于 routes: routes
    })

// 4. 创建和挂载根实例。
// 记得要通过 router 配置参数注入路由，
// 从而让整个应用都有路由功能
    //var map={};for(var i=0;i<a.length;i++){var h=$(a[i]).find("a")[0].href; var index= h.indexOf("#");var hre=h.substr(index+1,h.length);if($(a[i]).find("span").html()&&hre){map[hre] =$(a[i]).find("span").html()} }
    //routes.forEach(function(val,index){val.meta={tittle:map[val.path] }    })
    var  app;
    var index=0;
    router.beforeEach(function(to, from, next) {
        try{
            if(app ){
                var  allHistory={};
                app.$data.history.forEach(function (value) {
                    allHistory[value.path]=value.tittle;
                })
                if(!allHistory[from.path]){
                    app.$data.history.unshift({tittle:from.meta.tittle,path:from.path});
                }
                app.$data.history=JSON.parse(JSON.stringify(app.$data.history.slice(0,6)));
            }

            next();
            if(allrights.init){
                to.params.rights = allrights[to.path]?allrights[to.path].rights?allrights[to.path].rights:[]:[];
                to.params.rights.init=true;
            }else{
                to.params.rights=[];
                to.params.rights.init=false;
            }
        }catch(e){
            console.log(e);
        }

    });

    app = new Vue({
        el:"#sb-site",
        router:router,
        data:{
            tittle:"首页",
            index:false,
            rights:[],
            style:"",
            newMessage:0,
            hasMessage:false,
            now:moment().format("YYYY-MM-DD  HH:mm:ss"),
            contextPath:basepath,
            leftExtend:false,
            history:[],
            allHistory:{}
        },
        methods:{
            updateHistory: function(history){
                this.history = history;
            }
        },
        mounted:function () {
            var $this = this;

            if(allrights.init){
                $this.rights = allrights['/ftl/fbo/index']?allrights['/ftl/fbo/index'].rights?allrights['/ftl/fbo/index'].rights:[]:[];
                if($this.rights.length>0){
                    $this.rights=$this.rights.map(function (data) {
                        return data;
                    })
                    var parent = allrights['/ftl/fbo/index'];
                    if(parent.children){
                        parent.children.forEach(function (data) {
                            if(data.rights&&data.rights.length>0)
                                $this.rights=$this.rights.concat(data.rights);
                        })
                    }
                }
                $this.rights.init=true;
            }else{
                $this.rights=[];
                $this.rights.init=false;
            }
        },
        created:function (){
            var $this = this;
            setInterval(function () {
                $this.$set($this,'now',moment().format("YYYY-MM-DD  HH:mm:ss"));
            },1000);
            messages.$on('change',function(value) {
                $this.newMessage=0;
                if(value=="index"){
                    $this.tittle="欢迎光临智慧通航1.0";
                    $this.index = true;

                }else{
                    $this.tittle = value;
                    $this.index = false;
                    $this.style="";
                }
                document.title= $this.tittle;
            });
            messages.$on('hasMessage',function (value) {
                $this.hasMessage=value;
            });
            messages.$on('notHandelMgCount',function(value){
                $this.newMessage=value;
            });
            messages.$on('style',function(value) {
                $this.style=value;
            });

        }
    }).$mount('#app')
});

